package cn.dianchiyun.protocol.netty.dtu;

import cn.dianchiyun.protocol.netty.consts.Const;
import cn.dianchiyun.protocol.netty.dtu.handler.MyDecoderHandler1;
import cn.dianchiyun.protocol.netty.dtu.handler.MyServerHandler;
import cn.dianchiyun.protocol.netty.dtu.handler.impl.EncodeHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.concurrent.TimeUnit;

/**
 * 车联网，物联网，医院HIS，OA，商城等高端代码获取或者代码有疑问，加wx：17725354261，技术群：256860212，今日头条：大数据java架构师，公众号：前劲科技
 */
public class ChildChannelHandler extends ChannelInitializer<SocketChannel> {

	private static final Logger logger = LogManager.getLogger("dtu_server");
	
	@Override
	protected void initChannel(SocketChannel sc) throws Exception {
		//先硬编码，待得到确认数据后改为配置的
		sc.pipeline().addLast(new IdleStateHandler(Const.maxIdleTime,
				Const.maxIdleTime, Const.maxIdleTime, TimeUnit.SECONDS));

		//sc.pipeline().addLast(new EncodeHandler());
		//sc.pipeline().addLast(new ServerHandler());


		//sc.pipeline().addLast(new DecodeHandler());
		/*sc.pipeline().addLast(new MyDecoder());
		sc.pipeline().addLast(new EncodeHandler());
		sc.pipeline().addLast(new TestHandler());*/



		sc.pipeline().addLast(new MyDecoderHandler1());
		sc.pipeline().addLast(new EncodeHandler());
		sc.pipeline().addLast(new MyServerHandler());

		/*sc.pipeline().addLast(new StringDecoderHandler());
		sc.pipeline().addLast(new EncodeHandler());
		sc.pipeline().addLast(new StringServerHandler());*/


	}

}
